<?php

namespace Helpers;

class EnumList{

    /**
     * 获取字段枚举
     *
     * @param null $field
     * @return array
     *
     * create by ck 20170406
     * modify by ck 20170426    有字段传入则返回相应内容
     */
    public static function getFieldEnumList($field = null)
    {
        $enumList = [
            //应用
            'iAppType'      => [
                1   => '公司应用',
                2   => '外部应用',
                3   => '保留应用'
            ],
            'bAppApart'     => [
                0   => '否',
                1   => '是'
            ],
            'bOutSchool'    => [
                0   => '否',
                1   => '是'
            ],
            'bAppDown'      => [
                1   => '是',
                0   => '否'
            ],
            'bAppEnable'    => [
                1   => '是',
                0   => '否'
            ],
            'iAppSystem'    => [
                1   => 'Android',
                2   => 'IOS'
            ],
            'bAppHide'      =>[
                0   => '否',
                1   => '是'
            ],
            'iUpdateLevel'  => [
                1   => '无需更新',
                2   => '推荐更新',
                3   => '强制更新'
            ],
            'bDWEnable'     => [
                1   => '是',
                0   => '否'
            ],
            'iRetainType'   => [
                1   => '公司应用',
                2   => '外部应用',
                3   => '导入应用'
            ],
            //用户
            'iUserSex'      => [
                1   => '男',
                2   => '女',
                0   => '未知'
            ],
            'bDisable'      => [
                0   => '否',
                1   => '是'
            ],
            'bCompany'      => [
                0   => '否',
                1   => '是'
            ],
            //学校
            'bWelfare'      => [
                0   => '否',
                1   => '是'
            ],
            'iStatus'       => [
                0   => '未上线',
                1   => '上线',
                2   => '运营',
                3   => '停用'
            ],
            'iSAType'       => [
                1   => '学生组',
                2   => '教师组'
            ],
            'bSAGEnable'       => [
                1   => '是',
                0   => '否'
            ],
            //题库
            'bAudio'        => [
                0   => '否',
                1   => '是'
            ],
            'bDict'        => [
                0   => '否',
                1   => '是'
            ],
            //问卷
            'bAskEnable'    => [
                1   => '是',
                0   => '否'
            ],
            'iQueType'      => [
                1   => '单选题',
                2   => '多选题',
                3   => '下拉框',
                4   => '单行文本框',
                5   => '多行文本框'
            ],
            'bRequire'  => [
                1   => '是',
                0   => '否'
            ]
        ];
        return $field ? $enumList[$field] : $enumList;
    }

    /**
     * 根据列名返回枚举编号
     *
     * @return array
     *
     * create by ck 20160602
     * modify by ck 20160822    数值更改
     */
    public static function getFieldEnumId()
    {
        return [
            //用户
            'iUserType'     => 60,
            'iGradeCode'    => 62,
            //应用
            'iAppTarget'    => 65,
            //资源包
            'iSortCode'     => 67,
        ];
    }

    /**
     * 根据数据表名获取Modal名称及关键词字段名
     *
     * @param $tableName
     * @return mixed
     *
     * create by ck 20160701
     */
    public static function getModelInfoByName($tableName)
    {
        $modalInfo = [
            'XHSchool_Info'         => ['modalName' => '\\Admin\\Models\\school\\XhschoolInfo',         'modalId' => 'iSchoolId'],
            'XHSchool_AppGroup'     => ['modalName' => '\\Admin\\Models\\school\\XhschoolAppgroup',     'modalId' => 'iSAGId'],
            'XHApp_Store'           => ['modalName' => '\\Admin\\Models\\app\\XhappStore',              'modalId' => 'iAppId'],
            'XHApp_Droidwall'       => ['modalName' => '\\Admin\\Models\\app\\XhappDroidwall',          'modalId' => 'iDWId'],
            'XHRes_QuestionBank'    => ['modalName' => '\\Admin\\Models\\res\\XhresQuestionbank',       'modalId' => 'iQBankId'],
            'XHRes_ResourcePack'    => ['modalName' => '\\Admin\\Models\\res\\XhresResourcepack',       'modalId' => 'iRPId'],
            'XHFaq_Info'            => ['modalName' => '\\Admin\\Models\\faq\\XhfaqInfo',               'modalId' => 'iFAQId'],
            'XHAsk_Question'        => ['modalName' => '\\Admin\\Models\\ask\\XhaskQuestion',           'modalId' => 'iAQId'],
            'XHSys_User'            => ['modalName' => '\\Admin\\Models\\user\\XhsysUser',              'modalId' => 'iUserId'],
            'XHOvert_MsgTemplate'   => ['modalName' => '\\Admin\\Models\\overt\\XhovertMsgtemplate',    'modalId' => 'iMTId'],
            'XHTrack_Task'          => ['modalName' => '\\Admin\\Models\\track\\XhtrackTask',    '       modalId' => 'iTTId'],

            'Read_Columns'          => ['modalName' => '\\Admin\\Models\\read\\Channel',                'modalId' => 'id'],
            'Read_Marker'           => ['modalName' => '\\Admin\\Models\\read\\Channel',                'modalId' => 'id'],
            'Excellent_Student'           => ['modalName' => '\\Admin\\Models\\buy\\ExcellentStudent',                'modalId' => 'id'],
        ];
        isset($modalInfo[$tableName]) or die('未配置模型信息！');
        return $modalInfo[$tableName];
    }

}